import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;

public class MyOptionDialog extends JDialog {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2934049559859435919L;
	
	private boolean selection = false;
	
	public MyOptionDialog(JFrame parent, int x, int y) {
		super(parent, "", true);
		
		JButton okButton = new JButton("   OK   ");
    	JButton cancelButton = new JButton("CANCEL");
    	okButton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				selection = true;
				dispose();
			}
		});
    	cancelButton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});
    	setLayout(new FlowLayout());
    	getContentPane().add(okButton);
    	getContentPane().add(cancelButton);
    	setUndecorated(true);
        setAlwaysOnTop(true);
        pack();
        
        //TODO fixed alignment
        setLocation(x - getWidth(), y);
	}
	
	public boolean getOption() {
		setVisible(true);
		return selection;
	}
}
